<template>
  <div ref="container">
    <el-container class="designer-container">
      <el-aside width="250px">
        <left-aside ref="left-aside" :designer="designer"></left-aside>
      </el-aside>

      <el-container class="designer-center-container" direction="vertical">
        <div class="content">
          <tools :designer="designer"></tools>
          <div id="container"></div>
        </div>
      </el-container>

      <!--属性窗口-->
      <el-dialog v-dialogDrag :modal="false" :visible.sync="settingVisible" :append-to-body="true" :modal-append-to-body="true" width="400px" top="5vh" title="属性设置" class="attribute-config-container">
        <el-tabs value="widget">
          <el-tab-pane :label="`属性${designer.cellName?`[${designer.cellName}]`:''}`" name="widget">
            <el-scrollbar :noresize="false" :native="false" wrap-class="config scrollbar-wrap">
              <property-config :designer="designer"></property-config>
            </el-scrollbar>
          </el-tab-pane>
          <el-tab-pane label="数据源" name="form">
            <el-scrollbar :noresize="false" :native="false" wrap-class="config scrollbar-wrap">
              <datasource-config :designer="designer"></datasource-config>
            </el-scrollbar>
          </el-tab-pane>
        </el-tabs>
      </el-dialog>
    </el-container>
  </div>
</template>

<script>
import propertyConfig from "./components/propertyConfig";
import datasourceConfig from "./components/datasourceConfig";
import { loadJs } from "./util/index.js";
import LeftAside from "./components/leftAside";
import tools from "./components/tools";
import UReportDesigner from "./util/designer.js";
import buildLocal from "./util/i18n/i18n.js";
import "handsontable/dist/handsontable.full.min.css";

export default {
  name: "sys-dev-tools-bi-designer",
  components: {
    propertyConfig,
    datasourceConfig,
    LeftAside,
    tools,
  },
  data() {
    return {
      // 参数设置窗口显示
      settingVisible: true,
      // 设计器
      designer: {
        rowIndex: 0,
        colIndex: 0,
        row2Index: 0,
        col2Index: 0,
        cellName: null, // 单元格名称
        cellDef: {}, // 单元格数据
      },
    };
  },
  mounted() {
    buildLocal();
    this.designer = new UReportDesigner("container", this);

    loadJs(
      "https://auod-beijing.oss-cn-beijing.aliyuncs.com/ace/src-min-noconflict/ace.js"
    );
  },
  deactivated() {
    this.settingVisible = false;
  },
  activated() {
    this.settingVisible = true;
    // SaaS模块权限
    this.common.hasSaaSAuth("打印模板设置", this.$refs.container);
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
@import "./styles/index.scss";
::v-deep .handsontable table.htCore {
  border-collapse: collapse;
}

.el-container {
  height: 100% !important;
}

.el-radio + .el-radio {
  margin-left: 0 !important;
}
.el-radio {
  margin-right: 30px;
  line-height: 32px;
}
.el-checkbox + .el-checkbox {
  margin-left: 0 !important;
}
.el-checkbox {
  margin-right: 30px;
}
.designer-center-container {
  margin-bottom: 10px;
}

.attribute-config-container {
  ::v-deep .el-tabs__header {
    margin: 0;
  }
}
</style>
